package com.das.metrocloud.ssoserver.resource;

import com.das.framework.web.rs.service.*;
import org.springframework.stereotype.*;
import com.das.metrocloud.ssoserver.service.*;
import org.springframework.beans.factory.annotation.*;
import com.das.metrocloud.ssoserver.config.*;
import com.das.framework.common.extvo.*;
import javax.ws.rs.*;

@Component
@Path("/auth/authorization")
@Produces({ "application/json;charset=UTF-8" })
public class UserAuthorizationResource extends SupportResource
{
    @Autowired
    private AuthorizationService authorizationService;
    @Autowired
    private AuthKeyConfig keyConfig;
    
    @POST
    public ResultVO authorization(@QueryParam("token") final String token) {
        return this.authorizationService.authorization(token);
    }
    
    @POST
    @Path("/userPubKey")
    public ResultVO getServicePublicKey(@QueryParam("clientId") final String clientId, @QueryParam("secret") final String secret) throws Exception {
        final ResultVO resultVO = new ResultVO();
        resultVO.setData((Object)this.keyConfig.getUserPubKey());
        resultVO.setMessage("\u5bc6\u94a5\u8ba4\u8bc1\u6210\u529f");
        return resultVO;
    }
    
    @POST
    @Path("/hasPermission")
    public ResultVO hasPermission(@QueryParam("token") final String token, @QueryParam("code") final String code) {
        UserAuthorizationResource.log.debug(">>>>\u5f00\u59cb\u8ba4\u8bc1,Token::" + token + ", Code:" + code);
        return this.authorizationService.hasPermission(token, code);
    }
}
